home *** CD-ROM | disk | FTP | other *** search
- Glydo.App = Prototype.Class.create({
- initialize: function() {
- Glydo.Prefs.subscribe("",this.onPrefChanged);
- this.window = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
- .getInterface(Components.interfaces.nsIWebNavigation)
- .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
- .rootTreeItem
- .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
- .getInterface(Components.interfaces.nsIDOMWindow);
- this.browserBridge = new Glydo.BrowserBridge();
- this.browserBridge.addListener(this);
- },
-
- onPrefChanged: function(pref,value) {
- Glydo.LOGGING_DB.logUserEvent("application.prefs." + pref,"change",null,value);
- },
-
- onWindowLoaded: function(theWindow) {
- if (!this.window.menubar.visible || !this.window.toolbar.visible) {
-
- var sbp = this.window.document.getElementById("glydo-statusbarpanel");
- if (sbp) {
- sbp.hidden = true;
- }
- this.enabled = false;
- return;
- }
- this.enabled = true;
- this.documentManager = new Glydo.DocumentManager();
- this.statusbar = new Glydo.Statusbar(this);
- this.detachedPopupsManager = new Glydo.DetachedPopupsManager(this);
- this.teasersManager = new Glydo.TeasersManager(this);
- this.sharing = new Glydo.Sharing(this);
- this.browserBridge.addListener(this.documentManager);
- this.documentManager.addListener(this.statusbar);
- this.documentManager.addListener(this.detachedPopupsManager);
- this.documentManager.addListener(this.teasersManager);
- this.detachedPopupsManager.addListener(this.statusbar);
- this.detachedPopupsManager.addListener(this.teasersManager);
- this.documentManager.onTabSelect(this.window.getBrowser().selectedBrowser);
- Glydo.LOGGING_DB.logUserEvent("browser.window","new",null,null);
- // Register recommendation events
- Glydo.VERSIONS_MANAGER.showWelcomePageIfNecessary(this.window);
- },
-
- onWindowUnloaded: function(theWindow) {
- Glydo.LOGGING_DB.logUserEvent("browser.window","close",null,null);
- },
-
- openSettingsDialog: function() {
- var features = 'resizable=no, chrome=yes, centerscreen=yes';
-
- window.open('chrome://glydo/content/ui/settings/settings.xul', '', features);
- },
-
- openAboutDialog: function() {
- var features = 'resizable=no, chrome=yes, centerscreen=yes';
- window.open('chrome://glydo/content/ui/about/about.xul', '', features);
- },
-
- openFeedbackPage: function() {
- Glydo.WindowUtils.goToURL(window,'http://www.glydo.com/feedback.php?client_id='+encodeURIComponent(Glydo.CLIENT_INFO.clientId) + '&client_time=' + encodeURIComponent(Glydo.Utils.toISO8601DateString(new Date())),'new-tab');
- },
-
- followRecommendation: function(rec,mode,url,re_kind,re_position) {
- if (!rec) {
- return;
- }
- url = url || rec.url;
- var dest = Glydo.WindowUtils.goToURL(window,url,mode);
- if (rec.documentEntry &&
- (rec.documentEntry.resultSource === "server") &&
- rec.documentEntry.requestTime &&
- rec.documentEntry.responseTime) {
- Glydo.LOGGING_DB.logRecAction(rec.recSetId,rec.id,"OPEN",dest,re_kind,re_position);
- }
- },
-
-
- openRecommendationFeedback: function(rec) {
- if (rec) {
- var features = 'resizable=yes, chrome=yes, centerscreen=yes';
- window.openDialog('chrome://glydo/content/ui/feedback/recommendation_feedback.xul', '', features, rec, Prototype.F.bind(this.onRecommendationFeedbackSend,this));
- }
- },
-
- onRecommendationFeedbackSend: function(rec) {
-
- var f = new Glydo.Feedback(rec);
- f.send();
- },
-
- getContextRecommendationLink: function() {
- var popupNode = document.popupNode;
- for (; popupNode && (!popupNode.rec || !popupNode.href); popupNode = popupNode.parentNode) {
- }
- return popupNode;
- },
-
- onRecommendationContextMenu: function(event) {
- var popupNode = this.getContextRecommendationLink();
- var menu = event.target;
- if (menu) {
- if (popupNode) {
- Prototype.E.removeClassName(menu,"glydo-no-recommendation-context");
- } else {
- Prototype.E.addClassName(menu,"glydo-no-recommendation-context");
- }
- }
- return this.detachedPopupsManager.onContextMenu(event);
- },
-
- openContextRecommendation: function(mode) {
- var popupNode = this.getContextRecommendationLink();
- if (!popupNode) {
- return;
- }
- this.followRecommendation(popupNode.rec,mode,popupNode.href,popupNode.realEstateKind,popupNode.realEstatePosition);
- },
-
- openContextRecommendationFeedback: function() {
- var popupNode = this.getContextRecommendationLink();
- if (!popupNode) {
- return;
- }
- this.openRecommendationFeedback(popupNode.rec);
- },
-
- generateThumbnailServiceURL: function(rec) {
- var s = Glydo.App.GIRAFA_SIGNATURE_KEY + rec.url;
- var sig = Glydo.Utils.md5(s);
- sig = sig.substring(sig.length-16);
- var gurl = Glydo.App.GIRAFA_SITE_THUMBNAIL_URL_TEMPLATE.evaluate({
- clientId: encodeURIComponent(Glydo.App.GIRAFA_CLIENT_ID),
- signature: encodeURIComponent(sig),
- url: encodeURIComponent(rec.url)
- });
- return gurl;
- },
-
-
- });
-
- Glydo.App.GIRAFA_CLIENT_ID = "sc0102142";
- Glydo.App.GIRAFA_SIGNATURE_KEY = "glydokey";
- Glydo.App.GIRAFA_SITE_THUMBNAIL_URL_TEMPLATE = new Prototype.Template("http://scst.srv.girafa.com/srv/i?i=#{clientId}&s=#{signature}&r=#{url}");
-